import time
import random
import string


def en_check() -> str:
    """
    通过10位长度时间戳 映射Map生成随机字符串
    :return: 10位长度随机字符
    """
    Map = {'0': ['d', 'I', 'O', 'T'], '1': ['m', 't', 'v', 'V'], '2': ['c', 'l', 'r', 'w', 'A', 'B', 'M', 'Q'], '3': ['a', 'W', 'Z'], '4': ['G'], '5': ['b', 'u', 'y', 'Y'], '6': ['p', 's', 'D', 'F', 'H', 'J', 'N'], '7': ['n', 'o', 'x', 'C', 'K', 'L', 'R', 'U'], '8': ['f', 'j', 'k', 'q', 'E', 'P', 'X'], '9': ['e', 'g', 'h', 'i', 'z', 'S']}
    code = int(time.time())
    en_code = ''
    for i in str(code):
        en_code += random.choice(Map[i])
    return en_code


def de_check(code: str) -> str:
    """
    还原字符串为时间戳
    :param code: 10位长度随机字符
    :return: 10位长度时间戳
    """
    Map = {'a': '3', 'b': '5', 'c': '2', 'd': '0', 'e': '9', 'f': '8', 'g': '9', 'h': '9', 'i': '9', 'j': '8', 'k': '8', 'l': '2', 'm': '1', 'n': '7', 'o': '7', 'p': '6', 'q': '8', 'r': '2', 's': '6', 't': '1', 'u': '5', 'v': '1', 'w': '2', 'x': '7', 'y': '5', 'z': '9', 'A': '2', 'B': '2', 'C': '7', 'D': '6', 'E': '8', 'F': '6', 'G': '4', 'H': '6', 'I': '0', 'J': '6', 'K': '7', 'L': '7', 'M': '2', 'N': '6', 'O': '0', 'P': '8', 'Q': '2', 'R': '7', 'S': '9', 'T': '0', 'U': '7', 'V': '1', 'W': '3', 'X': '8', 'Y': '5', 'Z': '3'}
    de_code = ''
    for i in code:
        de_code += str(Map[i])
    return de_code


def getMap():
    """
    生成Map, 打印输出, 手动替换
    :return:
    """
    Map_1 = {}
    Map_2 = {str(_): [] for _ in range(10)}
    arr = [_ for _ in string.ascii_letters]
    for a in arr:
        n = random.randint(0, 9)
        Map_2[str(n)].append(a)
        Map_1[a] = str(n)
    print(Map_1)
    print(Map_2)
